<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1"><title id="co20941">DROP AGGREGATE</title><body><p id="sql_command_desc">Removes an aggregate function.</p><section id="section2"><title>Synopsis</title><codeblock id="sql_command_synopsis">DROP AGGREGATE [IF EXISTS] <varname>name</varname> ( <varname>aggregate_signature</varname> ) [CASCADE | RESTRICT]</codeblock>
  <p>where <varname>aggregate_signature</varname> is:</p>
  <codeblock>* |
[ <varname>argmode</varname> ] [ <varname>argname</varname> ] <varname>argtype</varname> [ , ... ] |
[ [ <varname>argmode</varname> ] [ <varname>argname</varname> ] <varname>argtype</varname> [ , ... ] ] ORDER BY [ <varname>argmode</varname> ] [ <varname>argname</varname> ] <varname>argtype</varname> [ , ... ]</codeblock>
</section><section id="section3"><title>Description</title><p><codeph>DROP AGGREGATE</codeph> will delete an existing aggregate function.
To run this command the current user must be the owner of the aggregate
function.</p></section><section id="section4"><title>Parameters</title><parml><plentry><pt>IF EXISTS</pt><pd>Do not throw an error if the aggregate does not exist. A notice is
issued in this case. </pd></plentry>
    <plentry>
      <pt><varname>name</varname></pt>
      <pd>The name (optionally schema-qualified) of an existing aggregate function.</pd>
    </plentry>
    <plentry>
      <pt><varname>argmode</varname></pt>
      <pd>The mode of an argument:  <codeph>IN</codeph> or <codeph>VARIADIC</codeph>.
        If omitted, the default is <codeph>IN</codeph>.</pd>
    </plentry>
    <plentry>
      <pt><varname>argname</varname></pt>
      <pd>The name of an argument. Note that <codeph>DROP AGGREGATE</codeph> does not
        actually pay any attention to argument names, since only the argument data types
        are needed to determine the aggregate function's identity.</pd>
    </plentry>
    <plentry>
      <pt><varname>argtype</varname></pt>
      <pd>An input data type on which the aggregate function operates. To reference
        a zero-argument aggregate function, write <codeph>*</codeph> in place of the
        list of input data types. To reference an ordered-set aggregate function, write
        <codeph>ORDER BY</codeph> between the direct and aggregated argument
        specifications.</pd>
    </plentry>
    <plentry><pt>CASCADE</pt><pd>Automatically drop objects that depend on the aggregate function.
</pd></plentry><plentry><pt>RESTRICT</pt><pd>Refuse to drop the aggregate function if any objects depend on it.
This is the default. </pd></plentry></parml></section>
<section id="notes">
  <title>Notes</title>
  <p>Alternative syntaxes for referencing ordered-set aggregates are described under
    <codeph>ALTER AGGREGATE</codeph>.</p>
</section>
<section id="section5"><title>Examples</title><p>To remove the aggregate function <codeph>myavg</codeph> for type <codeph>integer</codeph>:</p><codeblock>DROP AGGREGATE myavg(integer);</codeblock>
  <p>To remove the hypothetical-set aggregate function <codeph>myrank</codeph>,
    which takes an arbitrary list of ordering columns and a matching list of direct
    arguments:</p>
  <codeblock>DROP AGGREGATE myrank(VARIADIC "any" ORDER BY VARIADIC "any");</codeblock>
</section><section id="section6"><title>Compatibility</title><p>There is no <codeph>DROP AGGREGATE</codeph> statement in the SQL standard.
</p></section><section id="section7"><title>See Also</title><p><codeph><xref href="ALTER_AGGREGATE.xml#topic1" type="topic" format="dita"/></codeph>,
            <codeph><xref href="CREATE_AGGREGATE.xml#topic1" type="topic" format="dita"
        /></codeph></p></section></body></topic>
